#!/usr/bin/node
const EventEmitter = require('events').EventEmitter;
const log = console.log;
const e = new EventEmitter();

setInterval(()=>{
  e.emit('hello');
},1000);

setTimeout(()=>{
  e.emit('bye');
},5000);

e.on('hello',()=>{
  log('hello');
});

e.on('bye',()=>{
  log('goodbye');
  process.exit(1);
});
